//下载express  npm i express -S
const express = require("express");
// 使用connect-history-api-fallback解决history模式下网页刷新404问题
const history = require('connect-history-api-fallback');

const app = express();

const port = 5005;

app.use(history())
// 指定当前目录下的static为静态资源
app.use(express.static(__dirname+'/static'))

// 请求地址
app.get("/person", (req, res) => {
  res.send({
    // 返回数据
    name: "tom",
    age: 18,
  });
});

// port 端口5005
app.listen(port, (err) => {
  if (!err) {
    console.log("服务器启动成功了！");
  } else {
    console.log(`Server running at  http://127.0.0.1:${port}`);
  }
});
